package com.fosu.dao;

import com.fosu.domain.ProductCategories;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

/**
 * @author zqa
 * @version 1.0
 * @date 2020/10/22 11:11
 */
@Mapper
@Repository
public interface ProductAndCategoriesDao {


    /**
     * 插入产品和标签之间的关系
     * @param productId 商品id
     * @param categoriesId 分类id
     */
    @Results(id = "productAndCategoriesMap", value = {
            @Result(property = "productId", column = "product_id"),
            @Result(property = "categoriesId", column = "categories_id"),
    })
    @Insert("insert into product_categories(product_id,categories_id) values(#{productId},#{categoriesId})")
    void save(int productId,int categoriesId);


    /**
     * 删除所有与有关的分类
     * @param productId 商品id
     */
    @Delete("delete from product_categories where product_id=#{productId}")
    void clean(int productId);
}
